home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7857 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: phcoms4.seri.philips.nl!news
  2. From: Harry Franken <H.Franken@nl.cis.philips.com>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Date question
  5. Date: Thu, 29 Feb 1996 11:26:46 -0800
  6. Organization: Philips Medical Systems Netherlands
  7. Message-ID: <3135FDF6.3802@nl.cis.philips.com>
  8. References: <4h3kpb$i3s@news.ysu.edu>
  9. NNTP-Posting-Host: dialin-01.ehv.cp.philips.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I; 16bit)
  14.  
  15. Jerry Tomko wrote:
  16. > Hello.   Does anyone know where I can find a program that,
  17. > when given the month, day, and year, will determine the
  18. > corrosponding day of the week (Sunday, Monday, Tuesday, etc..)?
  19. > Jerry.
  20. > --
  21.  
  22.  
  23. Hai jerry,
  24.  
  25. Using program below should do it. 
  26.  
  27. Harry.
  28. +-------------------------------------- start      -------------+
  29.   year    = ?
  30.   month   = ?
  31.   day     = ?
  32.  
  33.   if (month <= 2 )
  34.   {
  35.     year  = year - 1;
  36.     month = month + 12;
  37.   }
  38.  
  39.   previous_century = year / 100;
  40.   year = year - (previous_century * 100);
  41.   result = (((26001L) * (month - 2L) - 2000L) / 10000L)
  42.                 + day + year + (year / 4) +
  43.                 (previous_century / 4) - (2 * previous_century);
  44.  
  45.   day_in_week = (result - (result / 7L) * 7L) ;
  46. +--------------------------------------- end ----------------------+
  47.